﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using KPIS.GERP.GHRMS.DAL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.IDAL;
using KPIS.GERP.GHRMS.DALFactory;

namespace KPIS.GERP.GHRMS.BLL
{
    public sealed class SpecialSkillBLL : ISpecialSkillBLL
    {
        private static readonly ISpecialSkillDAL dal = DataAccess.CreateSpecialSkills();

        private SpecialSkillInfo skillInfo = new SpecialSkillInfo();
        private EmployeeInfo empInfo = new EmployeeInfo();
        private MasSpecialSkillTypeInfo typeInfo = new MasSpecialSkillTypeInfo();

       
        public IList<SpecialSkillInfo> ListSpecialSkill(Nullable<int> Sequence, Nullable<int> EmpSequence)
        {
            if (Sequence.HasValue)
                skillInfo.Sequence = (int)Sequence;
            if (EmpSequence.HasValue)
            {
                empInfo.Sequence = (int)EmpSequence;
                skillInfo.Employee = empInfo;
            }
            return dal.ListSpecialSkill(skillInfo);
        }
        public DataSet LoadSpecialSkill(Nullable<int> Sequence, Nullable<int> EmpSequence)
        {
            if (Sequence.HasValue)
                skillInfo.Sequence = (int)Sequence;
            if (EmpSequence.HasValue)
            {
                empInfo.Sequence = (int)EmpSequence;
                skillInfo.Employee = empInfo;
            }
            return dal.LoadSpecialSkill(skillInfo);
        }
        public void Insert(string Employee, string SpecialSkillType, string Description, string Remarks, int CreatedBy)
        {
            empInfo.Sequence = Employee.Length > 0 ? Int32.Parse(Employee) : 0;
            typeInfo.Sequence = SpecialSkillType.Length > 0 ? Int32.Parse(SpecialSkillType) : 0;
            try
            {
                dal.Insert(new SpecialSkillInfo(0, empInfo, typeInfo, Description, Remarks, "", CreatedBy, 0));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Update(int Sequence, string SpecialSkillType, string Description, string Remarks, int UpdatedBy)
        {
            typeInfo.Sequence = SpecialSkillType.Length > 0 ? Int32.Parse(SpecialSkillType) : 0;
            try
            {
                dal.Update(new SpecialSkillInfo(Sequence, empInfo, typeInfo, Description, Remarks, "", 0, UpdatedBy));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Delete(int Sequence, int UpdatedBy)
        {
            try
            {
                dal.Delete(Sequence, UpdatedBy);
            }
            catch
            {
                throw new Exception("");
            }
        }
    }
}
